<?php include(TEMPLATE_DIR . 'header.tpl'); ?>
<?php include(TEMPLATE_DIR . 'nav.tpl'); ?>

<div class="main">
	<div class="push_stat_title">
		<h2>Push主机<!--<?php echo (isset($output['date_label']) && strlen($output['date_label'])) ? '[<span style="color:#35AAE5;">' . $output['date_label'] . '</span>]' : ''; ?>--><?php echo (isset($output['date_label']) && strlen($output['date_label'])) ? $output['date_label'] : ''; ?>统计数据</h2>
		<div class="line"></div>
	</div>
	<script type="text/javascript" src="report/scripts/js/pstat.js"></script>
	<div class="search_box">
		<div class="search_date_option_box">
			<span class="title">选择时段:
			<?php $_options_name = 'date_scope'; ?>
			<?php include(TEMPLATE_DIR . 'options_link.tpl'); ?>
			</span>
		</div>
		<div class="serach_date_display">
			<div class="title">统计时段:
				<span><?php echo $output['stat_time_text']; ?></span>
			</div>
		</div>
		<div class="serach_date_display">
			<div class="title">未处理数:
				<label class="pend_num">
					<?php if ((int)$output['count_pending'] > 0): ?>
						<a href="<?php echo $this->joinUrl(array('do' => 'sd', 'query_date' => $query['date_scope'], 'search_status' => 0, 'from' => 3, 'qs' => $output['qs'])); ?>"><?php echo $output['count_pending']; ?></a>
					<?php else: ?>
						<?php echo $output['count_pending']; ?>
					<?php endif; ?>
				</label>
			</div>
		</div>
	</div>
	<div class="push_stat_table_box">
		<table class="push_stat_host_table" border="0" cellpadding="0" width="100%">
			<tr>
				<th>主机</th>
				<th>总数</th>
				<th>成功数量</th>
				<th>花费时间(成功)</th>
				<th>失败数量</th>
				<th>花费时间(失败)</th>
			</tr>
			<!-- 总计行 start -->
			<?php if(isset($output['data']['total']) && !empty($output['data']['total'])): ?>
				<tr class="all">
					<td><span>总计/均值</span></td>
					<td><?php echo $output['data']['total']['count_send_all']; ?></td>
					<td class="success_num"><?php echo $output['data']['total']['count_success']; ?></td>
					<td>
						<?php if (!is_null($output['data']['total']['avg_spend_time_success'])) : ?>
							<span class="second" title="<?php echo $this->format($output['data']['total']['avg_spend_time_success'], 'STD_FLOAT_TIME_FULL'); ?>">
								<?php echo $this->format($output['data']['total']['avg_spend_time_success'], 'STD_FLOAT_TIME'); ?>
							</span>
						<?php else: ?>
							<?php echo $this->format(null); ?>
						<?php endif; ?>
					</td>
					<td class="fail_num">
						<?php if ((int)$output['data']['total']['count_fail'] > 0) : ?>
							<a href="<?php echo $this->joinUrl(array('do' => 'sd', 'query_date' => $query['date_scope'], 'search_status' => -1, 'from' => 3, 'qs' => $output['qs'])); ?>"><?php echo $output['data']['total']['count_fail']; ?></a>
						<?php else: ?>
							<?php echo $output['data']['total']['count_fail']; ?>
						<?php endif; ?>
					</td>
					<td>
						<?php if (!is_null($output['data']['total']['avg_spend_time_fail'])) : ?>
							<span class="second" title="<?php echo $this->format($output['data']['total']['avg_spend_time_fail'], 'STD_FLOAT_TIME_FULL'); ?>">
								<?php echo $this->format($output['data']['total']['avg_spend_time_fail'], 'STD_FLOAT_TIME'); ?>
							</span>
						<?php else: ?>
							<?php echo $this->format(null); ?>
						<?php endif; ?>
					</td>
				</tr>		
			<?php endif; ?>
			<!-- 总计行 end -->
			<!-- rows start -->
			<?php if(!empty($output['data']['list'])): ?>
				<?php foreach ($output['data']['list'] as $row): ?>
					<tr>
						<td>
							<?php echo $this->format($row['hoststr'], null, '未知'); ?>
						</td>
						<td>
							<span class="stat-success">
								<?php echo (int)$row['count_send_all']; ?>
							</span>
						</td>
						<td>
							<span class="stat-success">
								<?php echo (int)$row['count_success']; ?>
							</span>
						</td>
						<td>
							<?php if (!is_null($row['avg_spend_time_success'])) : ?>
								<span class="second" title="<?php echo $this->format($row['avg_spend_time_success'], 'STD_FLOAT_TIME_FULL'); ?>"><?php echo $this->format($row['avg_spend_time_success'], 'STD_FLOAT_TIME'); ?></span>
							<?php else: ?>
								<?php echo $this->format(null); ?>
							<?php endif; ?>
						</td>
						<td>
							<span class="stat-fail">
								<?php if ((int)$row['count_fail'] > 0) : ?>
									<a href="<?php echo $this->joinUrl(array('do' => 'sd', 'query_date' => $query['date_scope'], 'search_host' => $row['hoststr'], 'search_status' => -1, 'from' => 3, 'qs' => $output['qs'])); ?>"><?php echo $row['count_fail']; ?></a>
								<?php else: ?>
									<?php echo (int)$row['count_fail']; ?>
								<?php endif; ?>
							</span>
						</td>
						<td>
							<?php if (!is_null($row['avg_spend_time_fail'])) : ?>
								<span class="second" title="<?php echo $this->format($row['avg_spend_time_fail'], 'STD_FLOAT_TIME_FULL'); ?>"><?php echo $this->format($row['avg_spend_time_fail'], 'STD_FLOAT_TIME'); ?></span>
							<?php else: ?>
								<?php echo $this->format(null); ?>
							<?php endif; ?>
						</td>
					</tr>	
				<?php endforeach; ?>
			<?php else: ?>
				<tr><td colspan="7"></td></tr>
			<?php endif; ?>
			<!-- rows end -->
		</table>
		<div class="push_stat_tips">
			注:默认显示当天，每台主机的统计数据.
		</div>
	</div>
</div>
<script type="text/javascript">
$(function(){
	// 加载表单初始设置
	pstat.loadForm('stat_search_form');
});
</script>
<?php include(TEMPLATE_DIR . 'footer.tpl'); ?>
